package com.cy.pj.common.bo;

import java.util.List;
/**
 * 此对象负责将Dao层查询的数据和分页信息进行封装
 * @author private
 *
 * @param <T>
 */
//@Data
public class PageObject<T> {
	/**当前页的页码值*/
	private Long pageCurrent;
	/**页面大小*/
	private Integer pageSize;
	/**总行数(通过查询获得)
	 * select count(*) from sys_logs
	 * */
	private Long rowCount;
	/**总页数(通过计算获得)
	 * (总条数-1)/行数 +1
	 * */
	private Long pageCount;
	/**当前页记录
	 * select *  -- 要干什么?要查什么
	 * from sys_logs  -- 从哪查
	 * where username like %#{username}%--条件
	 * limit #{从第几条开始查,0开始},#{每行显示几条}
	 * */
	private List<T> records;
	
	public PageObject() {
		super();
	}
	public PageObject(Long pageCurrent, Integer pageSize, Long rowCount, Long pageCount, List<T> records) {
		super();
		this.pageCurrent = pageCurrent;
		this.pageSize = pageSize;
		this.rowCount = rowCount;
		this.pageCount = pageCount;
		this.records = records;
	}
	public PageObject (Long rowCount,Long pageCurrent,Integer pageSize,List<T> records) {
		this.rowCount = rowCount;
		this.pageCurrent = pageCurrent;
		this.pageSize = pageSize;
		this.records = records;
		this.pageCount = (rowCount-1)/pageSize+1;
	}
//	public PageObject(Integer pageCurrent,Integer pageSize,Integer rowCount,List<T> records){
//		this.pageCurrent = pageCurrent;
//		this.pageSize = pageSize;
//		this.rowCount = rowCount;
//		this.records = records;
//		/* 这行代码我们分几种情况去考虑
//		 * 1)本来是正好能显示全也就是不存在除不尽:9条数据,一页显示3条,应该有3页,计算结果(9-1)/3+1=3
//		 * 2)本来就除不尽需要多加一页:8条/10条数据,一页显示3条,应该有3页/4页,计算结果(8-1)/3+1=3 || (10-1)/3+1=4
//		 */
//		this.pageCount = (rowCount-1)/pageSize + 1;
//	}
	public Long getPageCurrent() {
		return pageCurrent;
	}
	public void setPageCurrent(Long pageCurrent) {
		this.pageCurrent = pageCurrent;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Long getRowCount() {
		return rowCount;
	}
	public void setRowCount(Long rowCount) {
		this.rowCount = rowCount;
	}
	public Long getPageCount() {
		return pageCount;
	}
	public void setPageCount(Long pageCount) {
		this.pageCount = pageCount;
	}
	public List<T> getRecords() {
		return records;
	}
	public void setRecords(List<T> records) {
		this.records = records;
	}
	@Override
	public String toString() {
		return "PageObject [pageCurrent=" + pageCurrent + ", pageSize=" + pageSize + ", rowCount=" + rowCount
				+ ", pageCount=" + pageCount + ", records=" + records + "]";
	}
	
}
